<div id="memberMain">
  <div class="title"><h4>复消商品</h4></div>
  <div class="height18"></div>
  <div class="memberList clearfix">
    <div class="tableClass">
      <table class="EmailTable center" cellspacing="0" cellpadding="0">
        <tbody>
        <tr class="">
          <td><input type="checkbox" onchange="checkAll.call(this)">全选</td>
          <td width="30%">图片</td>
          <td width="30%">商品信息</td>
          <td></td>
          <td width="12%">金额</td>
          <td>操作</td>
        </tr>
        <tr class="noList showCss">
          <td colspan="8"><img src="./listNo.png" alt=""></td>
        </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>

<script type="text/javascript">

  var priceCount = 0;

  function checkAll() {
    priceCount = 0;
    if (this.checked === true) {
      $('input:checkbox').each(function () {
        this.checked = true;
        price = parseFloat($(this).parent().parent().find('.total_price').html())
        if (!price) {
          price = 0;
        }
        priceCount = priceCount + price;
        $('#sumCart').html(priceCount)
      })
    } else {
      $('input:checkbox').each(function () {
        this.checked = false;
        priceCount = 0;
        $('#sumCart').html(priceCount)
      })
    }
  }

  function checkOne() {
    if (this.checked === true) {
      price = parseFloat($(this).parent().parent().find('.total_price').html())
      priceCount = priceCount + price;
      $('#sumCart').html(priceCount)
    } else {
      price = parseFloat($(this).parent().parent().find('.total_price').html())
      priceCount = priceCount - price;
      $('#sumCart').html(priceCount)
    }
  }

  function del_cart($id) {
    $('body').mLoading('show');
    $.post('/account/cart-del', {id: $id}, function (data) {
      if (data.code == 1) {
        $('body').mLoading('hide');
        success(data.msg, function () {

          location.href = "";
        })
      } else {
        $('body').mLoading('hide');
        error(data.msg, function () {

        })
      }
    })
  }

  function buySum() {
    $('body').mLoading('show');
    list = [];
    $('input:checkbox').each(function () {
      if (this.checked == true) {
        list.push($(this).data('value'))
      }
    });
    var mailPostId = $('#mailPostId').val();
    if (!mailPostId) {
      $('body').mLoading('hide');
      error('请添加一个收件方式', function () {

      });
      return false;
    }
    if (list.length > 0) {
      $.post('/shop/rbuy', {
        list: list,
        wallet: $('#wallet').val(),
        mailPostId: $('#mailPostId').val()
      }, function (data) {
        if (data.code == 1) {
          $('body').mLoading('hide');
          success(data.msg, function () {

            location.href = "";
          })
        } else {
          $('body').mLoading('hide');
          error(data.msg, function () {

          })
        }
      })
    } else {
      $('body').mLoading('hide');
      error('请选择一件商品', function () {

      });
    }
  }
</script>
